<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>主页面</title>
</head>
<body>
<form action="list" method="get">
    <p>返回日期：<input type="text" name="returnDate"/>
    <input type="submit" value="查询">&nbsp;&nbsp;&nbsp;
    <input type="button" onclick="add()" value="新增">
    </p>
</form>
<table border="1">
    <tr>
        <td>姓名</td>
        <td>身份证</td>
        <td>电话</td>
        <td>出发城市</td>
        <td>返乡日期</td>
        <td>是否访谈</td>
        <td>创建日期</td>
        <td>操作</td>
    </tr>

    <c:forEach items="${list}" var="returnPerson">
        <tr>
            <td>${returnPerson.personName}</td>
            <td>${returnPerson.personId}</td>
            <td>${returnPerson.personPhone}</td>
            <td>${returnPerson.sendCity}</td>
            <td><fmt:formatDate value='${returnPerson.returnDate}' pattern='yyyy-MM-dd'/></td>
            <td>${returnPerson.interviewStatus}</td>
            <td><fmt:formatDate value="${returnPerson.createDate}" pattern="yyyy-MM-dd"/></td>

            <td>
                <a href="byId?id=${returnPerson.id}">修改</a>
                <a href="JavaScript:void(0)" onclick="del(${returnPerson.id})">删除</a>

            </td>
        </tr>
    </c:forEach>
</table>

<p>
    <a href="list?pageNo=1">首页</a>
    <a href="list?pageNo=${pageNo-1}">上一页</a>
    <a href="list?pageNo=${pageNo+1}">下一页</a>
    <a href="list?pageNo=${totalPages}">末页</a>
    &nbsp;&nbsp;
    共${totalCount}条记录
</p>

<script>
    function add(){
        location.href='add';
    }

    function del(id){
        let con=confirm('确认要删除'+id+'吗？')

        if (con){
            location.href='delete?id='+id;
        }
    }
</script>
</body>
</html>
